//
//  LYLTabBarController.m
//  XCF
//
//  Created by dllo on 16/6/6.
//  Copyright © 2016年 GroupNine. All rights reserved.
//

#import "LYLTabBarController.h"
#import "LXHomePageViewController.h"
#import "LFBReadViewController.h"
#import "YYMusicViewController.h"
#import "LYLMovieViewController.h"

@interface LYLTabBarController ()



@end

@implementation LYLTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar.layer.borderWidth = 0.5;
    self.tabBar.layer.borderColor = [UIColor colorWithRed:0.49 green:0.49 blue:0.49 alpha:1.00].CGColor;
    
    UINavigationController *homePageNav = [LXHomePageViewController defaultHomePageNavigationController];
    [self setupChildController:homePageNav imageName:@"tab_home_normal" selectedImage:@"tab_home_selected"];
    [homePageNav.tabBarItem setTitle:@"首页"];
    
    UINavigationController *readNav = [LFBReadViewController defaultReadNavigationController];
    [self setupChildController:readNav imageName:@"tab_read_normal" selectedImage:@"tab_read_selected"];
    [readNav.tabBarItem setTitle:@"阅读"];
    
    UINavigationController *musicNav = [YYMusicViewController defaultMusicNavigationController];
    [self setupChildController:musicNav imageName:@"tab_music_normal" selectedImage:@"tab_music_selected"];
    [musicNav.tabBarItem setTitle:@"音乐"];
    
    UINavigationController *movieNav = [LYLMovieViewController defaultMovieNavigationController];
    [self setupChildController:movieNav imageName:@"tab_movie_normal" selectedImage:@"tab_movie_selected"];
    [movieNav.tabBarItem setTitle:@"电影"];
    
//    self.tabBar.layer.borderWidth = 0.5;
//    self.tabBar.layer.borderColor = [UIColor colorWithRed:0.49 green:0.49 blue:0.49 alpha:1.00].CGColor;
}

/**  绑定各个控制器, 顺便设置属性 */
- (void)setupChildController:(UIViewController *)vc imageName:(NSString *)imgName selectedImage:(NSString *)selectedImgName {
    
    // 设置图片间距
    vc.tabBarItem.image = [[UIImage imageNamed:imgName] imageWithRenderingMode:1];
    [[UITabBar appearance] setTranslucent:NO];

    
    // 设置图片的不渲染
    UIImage *image = [[UIImage imageNamed:selectedImgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.selectedImage = image;
    
    [self addChildViewController:vc];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
